<?php
	include "common.php";
	session_start();
	error_reporting(0);
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$eid = $_SESSION['id'];
	$userFname = $_SESSION['userFname'];
	$userLname = $_SESSION['userLname'];
	$supervisor = $_SESSION['supervisor'];
	$role = $_SESSION['role'];
	
	$userSql = "SELECT * FROM user WHERE e_id = '$eid'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlResult = mysql_fetch_assoc($userSqlQuery);
	
	$email = $userSqlResult['email'];
	$notification = $userSqlResult['notification'];
	$timezone_offset = 6; // for getting local time offset hrs
	$systemDate = gmdate('y-m-d', time()+$timezone_offset*60*60);
	$compToday = strtotime($systemDate);
	
	$userSql = "SELECT * FROM user WHERE e_id = '$supervisor'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlQueryResult = mysql_fetch_assoc($userSqlQuery);	
	$supervisorFname = $userSqlQueryResult['f_name'];
	$supervisorLname = $userSqlQueryResult['l_name'];
	$supervisorName = $supervisorFname." ".$supervisorLname;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="emp_index.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="show_report.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="employee.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="work_night.php"><li><div id="employee"></div><p>Apply for</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_leave.php" class="active"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_black_box.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>view as: <a href="emp_leave.php?check=1">Apply for Leave</a> | <a href="emp_leave.php?check=2">Check Leave</a> | 
	<a href="emp_leave.php?check=3">Govt. Leave</a></p>
</div><!-- end of othrpage_1-->
<div class="page_content" style="margin:0px !important;">
	<?php
		$checkSubmit = $_GET['check'];
		if ($checkSubmit == 1)
		{
	?>
			<form method="post" action="get_leave.php">
			<table cellpadding="0" cellspacing="0" class="apply4leave_table hrpage_info_table" style="background:#FFF !important; text-align:left !important; width:auto !important;" align="center">
				<tr valign="top">
					<td class="add_user_td1">Employee Id</td>
					<td><input type="text" value="<?php echo $_SESSION['id']?>"  name="id" readonly=""/></td>
					<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Employee Name</td>
					<td><input type="text" value="<?php echo $_SESSION['userFname']?>"  name="name" readonly=""/></td>
					<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Supervisor Name</td>
					<td><input type="text" value="<?php echo $supervisorName;?>" name="super" readonly=""/></td>
					<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Leave Type</td>
					<td><select name="leaveType">
												<option value="Casual">Casual</option>
												<option value="Earn">Earn</option>
												<option value="Maternal">Maternal</option>
												<option value="Paternal">Paternal</option>
								</select>
					</td>
					<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Leave From</td>
					<td><select name="day">
													<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
													<option value="3">3</option><option value="4">4</option><option value="5">5</option>
													<option value="6">6</option><option value="7">7</option><option value="8">8</option>
													<option value="9">9</option><option value="10">10</option><option value="11">11</option>
													<option value="12">12</option><option value="13">13</option><option value="14">14</option>
													<option value="15">15</option><option value="16">16</option><option value="17">17</option>
													<option value="18">18</option><option value="19">19</option><option value="20">20</option>
													<option value="21">21</option><option value="22">22</option><option value="23">23</option>
													<option value="24">24</option><option value="25">25</option><option value="26">26</option>
													<option value="27">27</option><option value="28">28</option><option value="29">29</option>
													<option value="30">30</option><option value="31">31</option>
												</select>
												<select name="month"> 
													<option value="month1">Month</option><option value="1">January</option>
													<option value="2">February</option><option value="3">March</option><option value="4">April</option>
													<option value="5">May</option><option value="6">June</option><option value="7">July</option>
													<option value="8">august</option><option value="9">September</option>
													<option value="10">October</option><option value="11">November</option>
													<option value="12">December</option>
												</select>
												<select name="year">
													<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
													<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
													<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
													<option value="2020">2020</option>
													</select>
						</td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Leave From</td>
					<td><select name="day1">
													<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
													<option value="3">3</option><option value="4">4</option><option value="5">5</option>
													<option value="6">6</option><option value="7">7</option><option value="8">8</option>
													<option value="9">9</option><option value="10">10</option><option value="11">11</option>
													<option value="12">12</option><option value="13">13</option><option value="14">14</option>
													<option value="15">15</option><option value="16">16</option><option value="17">17</option>
													<option value="18">18</option><option value="19">19</option><option value="20">20</option>
													<option value="21">21</option><option value="22">22</option><option value="23">23</option>
													<option value="24">24</option><option value="25">25</option><option value="26">26</option>
													<option value="27">27</option><option value="28">28</option><option value="29">29</option>
													<option value="30">30</option><option value="31">31</option>
												</select>
												<select name="month1"> 
													<option value="month1">Month</option><option value="1">January</option>
													<option value="2">February</option><option value="3">March</option><option value="4">April</option>
													<option value="5">May</option><option value="6">June</option><option value="7">July</option>
													<option value="8">august</option><option value="9">September</option>
													<option value="10">October</option><option value="11">November</option>
													<option value="12">December</option>
												</select>
												<select name="year1">
													<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
													<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
													<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
													<option value="2020">2020</option>
													</select>
						</td>
						<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr valign="top">
					<td class="add_user_td1">Leave Reason</td>
					<td><textarea name="leave_reason" cols="52" rows="7"></textarea></td>
					<td style="width:10px; background:#eff2f6; padding:0px !important;">&nbsp;</td>

				</tr>
				<tr><td colspan="3"><p class="submit_button_add_user"><input type="submit" value="Submit" /></p></td></tr>
			</table>
		</form>	
	<?php
		}
		if ($checkSubmit ==2)
		{
	?>
			<p class="header_page_content" style="text-align:center !important;">Leave Report</p>
        <table cellpadding="0" cellspacing="0" align="center">
        	<tr class="table_header_1"  valign="top" width="300px;">            	
            	<td colspan="5">
                	<p>Casual Leave Report</p>
                </td>
            </tr>
            <tr valign="top" class="table_header_2">
            	<td width="60px"><p>Total Leave</p></td>
                <td width="60px;"><p>Enjoyed Leave</p></td>
                <td width="60px;"><p>Available Leave</p></td>                
            </tr>
             <?php				
				$collectId = "SELECT * FROM earn_casual_leave WHERE e_id = '$eid' and status='1'";
				$collectIdQuery = mysql_query($collectId);
				$collectIdFetchArray = mysql_fetch_array($collectIdQuery);
				$collectTotalCasualLeave = $collectIdFetchArray['t_casual_l'];
				$collectEnjoyedCasualLeave = $collectIdFetchArray['c_enjoyed'];
				$collectAvailableCasualLeave = $collectIdFetchArray['c_avail'];				
			?>
            <tr valign="top" class="table_header_3">
            	<td width="60px"><p><?php echo $collectTotalCasualLeave; ?></p></td>
                <td width="60px;"><p><?php echo $collectEnjoyedCasualLeave; ?></p></td>
                <td width="60px;"><p><?php echo $collectAvailableCasualLeave; ?></p></td>                
            </tr>           
        </table>
		<br /><br />
		<table cellpadding="0" cellspacing="0"  align="center">
        	<tr class="table_header_1"  valign="top" width="300px;">            	
            	<td colspan="3">
                	<p>Earn Leave Report</p>
                </td>
            </tr>
            <tr valign="top" class="table_header_2">
            	<td width="60px"><p>Total Leave</p></td>
                <td width="60px;"><p>Enjoyed Leave</p></td>
                <td width="60px;"><p>Available Leave</p></td>                
            </tr>
             <?php				
				$collectId = "SELECT * FROM earn_casual_leave WHERE e_id = '$eid' and status='1'";
				$collectIdQuery = mysql_query($collectId);
				$collectIdFetchArray = mysql_fetch_array($collectIdQuery);
				$collectTotalEarnLeave = $collectIdFetchArray['t_earn_l'];
				$collectEnjoyedEarnLeave = $collectIdFetchArray['enjoyed'];
				$collectAvailableEarnLeave = $collectIdFetchArray['available_leave'];				
			?>
            <tr valign="top" class="table_header_3">
            	<td width="60px"><p><?php echo $collectTotalEarnLeave; ?></p></td>
                <td width="60px;"><p><?php echo $collectEnjoyedEarnLeave; ?></p></td>
                <td width="60px;"><p><?php echo $collectAvailableEarnLeave; ?></p></td>                
            </tr>           
        </table>	
	<?php
		}
		if ($checkSubmit == 3)
	{
		$govtLeaveSql = "SELECT * FROM govt_holiday";
		$govtLeaveSqlQuery = mysql_query($govtLeaveSql);
		?>
		<div class="page_content1">
  		<table  border="0" cellpadding="0" cellspacing="0" class="header_page_content" width="800"  align="center">
        	<tr class="table_header_1"  valign="top">
            	<td align="center" colspan="8">List of Government Leave</td>
            </tr>
			<tr valign="top" class="table_header_2">
				<td width="100px"><p> Government Leave Title  </p></td>
				<td width="100px"><p> Leave Date  </p></td>
				<td width="100px"><p> Number of Days  </p></td>
				<td width="100px"><p> Dependancy on Moon</p></td>
			</tr>
    </table>
		
	<?php
	while ($data = mysql_fetch_assoc($govtLeaveSqlQuery))
	{
	?>
		<table class="header_page_content" border="0" cellpadding="0" cellspacing="0" width="800"  align="center">
			<tr valign="top" class="table_header_3">
				<td width="100px"><p><?php echo $data['heading'];?></p></td>
				<td width="100px"><p><?php echo $data['date'];?></p></td>
				<td width="100px"><p><?php echo $data['n_days'];?></p></td>
				<td width="100px"><p><?php if($data['dependancy'] == 1) echo "Yes"; else echo "No";?></p></td>
			</tr>
		</table>
		<?php
	}
	?>
    </div>
	<?php }	?>
</div>
<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->

</body>
</html>